package dao

import (
	"blog_server/internal/model/entity"
	"blog_server/pkg/app"
)

func (d Dao) GetAllFriendLink(page, pageSize int) (error, []entity.FriendLink) {
	var link entity.FriendLink
	return link.GetByPagination(d.engine, app.GetPageOffset(page, pageSize), pageSize)
}

func (d Dao) CreateFriendLink(link entity.FriendLink) error {
	return link.Create(d.engine)
}

func (d Dao) CountFriendLink() (error, uint) {
	var link entity.FriendLink
	return link.Count(d.engine)
}

func (d Dao) UpdateFriendLink(link *entity.FriendLink) error {
	return link.Update(d.engine)
}

func (d Dao) DeleteFriendLink(link *entity.FriendLink) error {
	return link.Delete(d.engine)
}

func (d Dao) GetFriendLinkListBySearchText(searchText string) ([]entity.FriendLink, error) {
	fl := &entity.FriendLink{}
	return fl.GetFriendLinkListBySearchText(d.engine, searchText)
}
